import { defineStore } from "pinia";
import { STORE_PREFIX } from "@/utils/constant";

export const useTimerStore = defineStore(
  `${STORE_PREFIX}timer_store`,
  () => {
    const timerList = ref([
      { name: "手动", value: 0 },
      { name: "10秒", value: 10 },
      { name: "20秒", value: 20 },
      { name: "30秒", value: 30 }
    ]);
    const monitorTimer = ref(0); // 监控定时
    const flyTimer = ref(0); // 飞单定时
    const userTimer = ref(0); // 用户定时

    const setMonitorTimer = (time: number) => {
      monitorTimer.value = time;
    };
    const setFlyTimer = (time: number) => {
      flyTimer.value = time;
    };
    const setUserTimer = (time: number) => {
      userTimer.value = time;
    };

    return {
      timerList,
      monitorTimer,
      flyTimer,
      userTimer,
      setMonitorTimer,
      setFlyTimer,
      setUserTimer
    };
  },
  {
    persist: {
      storage: localStorage
    }
  }
);
